package com.group2.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DbUtil {
	private String dbUrl = "jdbc:mysql://localhost:3306/courseselection_management_swing?serverTimezone=Asia/Shanghai";
	private String dbUserName = "root";
	private String dbPassword = "admin";
	private String jdbcName = "com.mysql.cj.jdbc.Driver";

	/**
	 * 
	 * 
	 * @return
	 * @throws Exception
	 */
	public Connection getCon() throws Exception {
		Class.forName(jdbcName);
		Connection con = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
		return con;
	}

	public void closeCon(Connection con) throws Exception {
		if (con != null) {

			con.close();
		}
	}

	public static void main(String[] args) {
		DbUtil dbUtil = new DbUtil();
		try {
			dbUtil.getCon();
			System.out.println("……!");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
